import React from 'react'
import { Switch, Route, BrowserRouter, Redirect } from 'react-router-dom';
import Loading from "./components/Loading.tsx"

export default function App() {
  return (
    <div>
      <React.Suspense fallback={<Loading></Loading>}>
      <BrowserRouter>
            <Switch>
              {/* 重定向 */}
              <Redirect exact from="/" to="/login"></Redirect>
              <Route path="/home" component={ React.lazy(() => import("./pages/home/index")) }></Route>
              <Route path="/login" component={ React.lazy(() => import("./pages/login/login")) }></Route>
              <Route path="/register" component={ React.lazy(() => import("./pages/register/register")) }></Route>
              <Route path="/404" component={ React.lazy(() => import("./components/NotFind")) }></Route>
              <Redirect to="/404"></Redirect>
            </Switch>
          </BrowserRouter>
          </React.Suspense>
    </div>
  )
}

